package com.fullstack.server.modules

import cats.effect.kernel.Resource
import cats.effect.std.Random
import cats.effect.{Async, MonadCancelThrow}
import cats.implicits.*
import com.fullstack.server.core.{LiveUsers, Users}
import doobie.util.transactor.Transactor
import org.typelevel.log4cats.Logger


final case class Core[F[_]] private(
                                    users: Users[F]
                                   )

object Core {

  def apply[F[_]: Async: Logger](xa: Transactor[F]): Resource[F, Core[F]] =

    val coreF =
      for
     
        users <- LiveUsers[F](xa)
        
      yield Core(users)

    Resource.eval(coreF)

}
